package com.itheima.app.controller;

import com.easemob.im.server.model.EMVideoMessage;
import com.itheima.app.manager.VideoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author 请不要叫我高司令
 * @Date 2022/3/23 18:35
 * @Version 1.0
 */

@RestController
public class VideoController {

    @Autowired
    private VideoManager videoManager;


    //推荐视频查询
    @GetMapping("/smallVideos")
    public ResponseEntity findVideoVoByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    ) {

        return videoManager.findVideoVoByPage(pageNum, pageSize);

    }


    //发布短视频
    @PostMapping("/smallVideos")
    public void saveVideo(MultipartFile videoThumbnail, MultipartFile videoFile) throws IOException {

        videoManager.saveVideo(videoThumbnail, videoFile);

    }


    //关注视频作者
    @PostMapping("/smallVideos/{focusUserId}/userFocus")
    public void userFocus(@PathVariable Long focusUserId) {

        videoManager.userFocus(focusUserId);

    }


    //取消关注视频作者
    @PostMapping("/smallVideos/{focusUserId}/userUnFocus")
    public void userUnFocus(@PathVariable Long focusUserId) {

        videoManager.userUnFocus(focusUserId);

    }

}
